package com.athena.dal.dao;

import java.util.List;

import javax.persistence.EntityManager;

import org.springframework.beans.factory.annotation.Autowired;

import com.athena.dal.entities.Subject;

/**
 * 
 * @author Ajit.Kumar1
 *
 */
public class SubjectDaoImpl implements SubjectDao {

	@Autowired
	private GenericDao genericDao;

	@Override
	public List<Subject> findAllSubjectsForDept(String departmentId) {
		List<Subject> subjects = null;
		if(genericDao != null && departmentId != null && !departmentId.isEmpty()){
			EntityManager entityManager = genericDao.getEntityManager();
			subjects = entityManager.createNamedQuery("Subject.findByDepartmentId").setParameter("departmentId", departmentId).getResultList();
		}
		return subjects;
	}

	@Override
	public List<Subject> findAllSubjectsOfDeptForClass(String departmentId, int classId) {
		List<Subject> subjects = null;
		if(genericDao != null && departmentId != null && !departmentId.isEmpty()){
			EntityManager entityManager = genericDao.getEntityManager();
			subjects = entityManager.createNamedQuery("Subject.findByDepartmentAndClassId").setParameter("departmentId", departmentId)
					.setParameter("classId", classId).getResultList();
		}
		return subjects;
	}
	
	
	
}
